package gdou.gym.returnvo;

import gdou.gym.exception.StateCode;

public class ResultVo {
    private Integer code;
    private String msg;
    private Object data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    // 手动设置返回vo
    public ResultVo(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    //返回状态码
    public ResultVo(StateCode stateCode) {
        this.code = stateCode.getCode();
        this.msg = stateCode.getMessage();
        this.data = null;
    }

    // 默认返回成功状态码，数据对象
    public ResultVo(Object data) {
        this.code = StateCode.SUCCESS.getCode();
        this.msg = StateCode.SUCCESS.getMessage();
        this.data = data;
    }

    // 返回指定状态码，数据对象
    public ResultVo(StateCode statusCode, Object data) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMessage();
        this.data = data;
    }
}
